﻿using RRQMCore.ByteManager;
using RRQMSocket;
using System;
using System.Text;

namespace JsonClient
{
    class Program
    {
        static void Main(string[] args)
        {
            LanTcpClient client = new LanTcpClient();
            client.Connect(new IPHost("127.0.0.1:5600"));
            Console.WriteLine("成功连接");

            while (true)
            {
                string msg = Console.ReadLine();
                byte[] bytes = Encoding.UTF8.GetBytes(msg);
                client.Send(bytes);
            }
            
        }
    }

    class LanTcpClient : TcpClient
    {
        protected override void HandleReceivedData(ByteBlock byteBlock, object obj)
        {
            string msg = Encoding.UTF8.GetString(byteBlock.Buffer, 0, (int)byteBlock.Length);
            Console.WriteLine($"接收的长度是{byteBlock.Length}，位置是{byteBlock.Position},信息是:{msg}");
        }
    }
}
